﻿using UnityEngine;
using System.Collections;

public class Blast : MonoBehaviour {

   
    float Speed = 15.0f;
	Transform Trnsfrm;
    Vector3 Vel;
	void Awake () {
	    Trnsfrm = transform;
        Vel = Trnsfrm.up *Speed;
         PlayerLayer = LayerMask.NameToLayer("Player");  
	}
	
	void Update () {
	    Trnsfrm.position += Vel*Time.deltaTime;
        if( Camera.main.WorldToScreenPoint(Trnsfrm.position).x < 0  )
            Destroy(gameObject);
	}
    int PlayerLayer;

    protected void OnTriggerEnter(Collider other) {
        
        if(other.gameObject.layer == PlayerLayer) {
            other.GetComponent<Character>().shove( Vel*100.0f, Trnsfrm.position);
        }
        Destroy( gameObject);
    }
}
